--[[

--]]


local delay = 3  -- in seconds
local new_timer = ngx.timer.at
local log = ngx.log
local ERR = ngx.ERR
local check

local upstream_server = ngx.shared.upstream_server

local function action()
  local i = upstream_server:get('i')
  if not i then
    upstream_server:set('i',1)
  else
    upstream_server:incr('i',1)
  end
end






check = function(premature)
  if not premature then

    action()
    -- do the health check or other routine work
    local ok, err = new_timer(delay, check)
    if not ok then
      log(ERR, "failed to create timer: ", err)
      return
    end
  end
end

local ok, err = new_timer(delay, check)
if not ok then
  log(ERR, "failed to create timer: ", err)
  return
end




